﻿
using System.Collections;
using DataAccess;
using Model;

namespace Service
{

    public class ReferenceDataService : ServiceBase
    {
        ReferenceDataAccess mgr;
        public ReferenceDataService()
        {
            mgr = new ReferenceDataAccess();
        }
        public void SaveGroupeSoftware(GroupeSoftware groupeSoftware)
        {
            mgr.Save(groupeSoftware);

        }
        public IList GetEquipmentTypeById(int equipmentTypeId)
        {

            return mgr.GetListByPropertyValueAndOrder(typeof(EquipmentType), EquipmentType.CONST_EQUIPMENTID, equipmentTypeId,
                                                   EquipmentType.CONST_EQUIPMENTTYPE_LABEL);
        }
       

        public IList GetProblemTypesByEquipTypeId(int equipmentTypeId)
        {

            return mgr.GetListByPropertyValueAndOrder(typeof(ProblemType), ProblemType.CONST_EQUIP_TYPE_ID, equipmentTypeId,
                                                   ProblemType.CONST_PROBLEM_TYPE_LABEL);
        }
        public void SaveEquipmentType(EquipmentType equipmentType)
        {
            mgr.Save(equipmentType);
        }
        public IList GetGroupeSoftware()
        {
            return mgr.GetByOrder((typeof(GroupeSoftware)), GroupeSoftware.CONST_GROUPESOFTWARE_LABEL);
        }

        public IList GetSoftwares()
        {
            return mgr.GetByOrder((typeof(EquipmentSoftware)), EquipmentSoftware.CONST_SOFTWARE_LABEL);
        }
        public IList GetProblemTypes()
        {
            return mgr.GetByOrder(typeof(ProblemType), ProblemType.CONST_PROBLEM_TYPE_LABEL);
        }



        //BUILDING
        public void SaveBuilding(Building model)
        {
            mgr.Save(model);
        }
        public void UpdateBuilding(Building model)
        {
            mgr.Save(model);
        }
        public void DeleteBuiding(Building model)
        {
            mgr.Delete(model);
        }
        public void DeleteBuilding(int equipmentId)
        {
            mgr.Delete(equipmentId);
        }

        public void SaveEmployee(Employee employee)
        {
            mgr.Save(employee);
        }
        public void SaveSystem(EquipmentSystem system)
        {
            mgr.Save(system);
        }


        public void SaveDepartment(Department department)
        {
            mgr.Save(department);
        }


        public void SaveCompany(Company  company)
        {
            mgr.Save(company);
        }
       
        // LOCATION 
        public void SaveLocation(Location model)
        {
            mgr.Save(model);
        }
        public void UpdateLocation(Location model)
        {
            mgr.Save(model);
        }
        public void UpdateSystem(EquipmentSystem system)
        {
            mgr.Save(system);
        }
        public void DeleteLocation(Location model)
        {
            mgr.Delete(model);
        }
        public void DeleteLocation(int equipmentId)
        {
            mgr.Delete(equipmentId);
        }

        public IList GetLocations()
        {
            return mgr.GetByOrder((typeof(Location)),Location.CONST_LOCATION_LABEL);
        }
        public IList GetModels()
        {
            return mgr.GetByOrder((typeof(EquipmentModel)), EquipmentModel.CONST_MODEL_LABEL);
        }
        public IList GetSuppliers()
        {
            return mgr.GetByOrder((typeof(Supplier)), Supplier.CONST_SUPPLIER_NAME);
        }
        public IList GetDepartments()
        {
            return mgr.GetByOrder((typeof(Department)), Department.CONST_DEPARTMENT_LABEL);
        }
        public IList  GetEmployees()
        {
            return mgr.GetListByPropertyValueAndOrder(typeof(Employee), Employee.CONST_IS_CONTINUE, false,Employee.CONST_EMPLOYEE_NAME);
        }
        public Employee GetEmployeeById(int employeeId)
        {
            return mgr.GetEmployeeById(employeeId);
        }
        public Employee GetEmployeeByDomainName(string domainName)
        {
            return mgr.GetEmployeeByDomainName(domainName);
        }
        public Employee GetEmployeeByUserName(string userName)
        {
            return mgr.GetEmployeeByUserName(userName);
        }
        public Employee IsEmployeeExist(string userName, string password)
        {
            return mgr.IsEmployeeExist(userName, password);
        }

        //public IList GetGroup()
        //{
        //    return mgr.GetByOrder((typeof(UserGroup)));
        //}
        public IList GetBuildings()
        {
            return mgr.GetByOrder(typeof(Building), Building.CONST_BUILDING_LABEL);
        }
        public IList GetEmployeesByDepartement(int departementId)
        {
            return mgr.GetListByPropertyValueAndOrder(typeof(Employee),Employee.CONST_DEPARTMENTID,departementId, Employee.CONST_EMPLOYEE_NAME);
        }
        
        public IList GetSystems()
        {
            return mgr.GetByOrder(typeof(EquipmentSystem),EquipmentSystem.CONST_SYSTEM_LABEL) ;
        }
        public IList GetEquipmentTypes(int systemId)
        {
            return mgr.GetListByPropertyValue(typeof(EquipmentTypeSystem), EquipmentSystem.CONST_SYSTEM_ID, systemId);
        }
        public IList GetEquipmentTypes()
        {
            return mgr.GetByOrder(typeof(EquipmentType), EquipmentType.CONST_EQUIPMENTTYPE_LABEL);
        }
        public IList GetUserGroups()
        {
            return mgr.GetByOrder(typeof(UserGroup), UserGroup.CONST_GROUP_LABEL);
        }
        public IList GetEquipmentTypeList(IList equipmentTypeSystem)
        {
            IList equipmentTypeList = new ArrayList();
            foreach (EquipmentTypeSystem o in equipmentTypeSystem)
            {
                equipmentTypeList.Add(o.EquipmentType);
            }
            return equipmentTypeList;
        }

        public IList GetEquipmentTypes(bool isSparepart)
        {
            return mgr.GetListByPropertyValueAndOrder(typeof(EquipmentType), EquipmentType.CONST_SPARE_PART,isSparepart,EquipmentType.CONST_EQUIPMENTTYPE_LABEL);
        }
        public IList GetCompanies()
        {
            return mgr.GetByOrder(typeof(Company), Company.CONST_COMPANY_LABEL);
        }

        public int GetDefaultSystemId()
        {
            IList list = mgr.GetListByPropertyValue(typeof (EquipmentSystem), EquipmentSystem.CONST_SYSTEM_LABEL,
                                                    "Other");
            return ((EquipmentSystem)list[0]).SystemId;
        }

        public EquipmentSoftware GetSoftwareBySoftId(int softwareId)
        {
            IList list = mgr.GetListByPropertyValue(typeof(EquipmentSoftware), EquipmentSoftware.CONST_SOFTWARE_ID, softwareId);
            return ((EquipmentSoftware)list[0]);
        }
        //public Employee GetEmployeeById(int employeeID)
        //{
        //    IList list = mgr.GetListByPropertyValue(typeof(Employee), Employee.CONST_EMPLOYEE_ID, employeeID);
        //    return ((Employee)list[0]);
        //}
        public int GetVGAId()
        {
            return mgr.GetVGAId();

        }
      
        public int GetRamId()
        {
            return mgr.GetRamId();

        }
        public int GetIntranetWORequestTypeId()
        {
            return mgr.GetIntranetWORequestTypeId();
        }

        public int GetSoundCardId()
        {
            return mgr.GetSoundCardId();

        }
        
        public int GetCPUId()
        {
            return mgr.GetCPUId();
        }
       
        public int GetNetworkCardId()
        {
            return mgr.GetNetworkCardId();

        }
        
        public int GetHardiskId()
        {
            return mgr.GetHardiskId();

        }
        public void SaveModel(EquipmentModel model)
        {
            mgr.Save(model);
        }
        public IList GetGroupSoftwares()
        {

            return mgr.GetByOrder((typeof(GroupeSoftware)), GroupeSoftware.CONST_GROUPESOFTWARE_LABEL);

        }
       
        public EquipmentTypeSystem GetEquipmentTypeSystem(int typeId, int systemId)
        {
            return mgr.GetEquipmentTypeSystem(typeId, systemId);
        }
        public EquipmentTypeModel GetEquipmentTypeModel(int typeId, int modelId)
        {
            return mgr.GetEquipmentTypeModel(typeId, modelId);
        }
        public void InsertEquipmentTypeSystem(EquipmentTypeSystem typeSystem)
        {
            mgr.Save(typeSystem);
        }
        public void InsertEquipmentTypeModel(EquipmentTypeModel model)
        {
            mgr.Save(model);
        }
        public void SaveSoftware(EquipmentSoftware software)
        {
            mgr.Save(software);
        }
        public  EquipmentTypeSystem GetEquipmentTypeSystem(int equipmentTypeId)
        {
            return
                mgr.GetListByPropertyValue(typeof(EquipmentTypeSystem), EquipmentTypeSystem.CONST_SYSTEMID,
                                           equipmentTypeId)[0] as EquipmentTypeSystem;
        }
        public IList GetRequestEmployees(int departmentId)
        {
            return mgr.GetRequestEmployees(departmentId);
        }
        public IList GetRequestEmployees()
        {
            return mgr.GetRequestEmployees();
        }
        public IList GetAssignedEmployees()
        {
            return mgr.GetAssignedEmployees();
        }
       



    }
}
